/*
 * @Author: sonss
 * @Date: 2024-08-22 18:21:30
 * @LastEditTime: 2024-08-28 21:33:56
 * @FilePath: /ss-file-antd/src/utils/file.ts
 * @Description:
 */

const descSize = (bytes: number): string => {
  if (bytes < 1000) return bytes + 'b';
  else if (bytes < 1000 * 1000) return (bytes / 1024).toFixed(2) + 'k';
  else if (bytes < 1000 * 1000 * 1000) return (bytes / (1024 * 1024)).toFixed(2) + 'm';
  else return (bytes / (1000 * 1000 * 1000)).toFixed(2) + 'g';
};

export { descSize };
